﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common.Core
{
	public class TimedOperation : IDisposable
	{
		readonly DateTime start;
		DateTime last;
		readonly string description;

		public TimedOperation( string description )
		{
			last = start = DateTime.Now;
			this.description = description;
		}

		public void Mark( string message )
		{
			Console.WriteLine( string.Format( "{0} - [{1}]", message, DateTime.Now.Subtract( last ).TotalSeconds ) );
			last = DateTime.Now;
		}

		void IDisposable.Dispose()
		{
			Console.WriteLine( string.Format( "{0} - [{1}]", description, DateTime.Now.Subtract( start ).TotalSeconds ) );
		}
	}
}
